<%@ page pageEncoding="UTF-8"%>
<%@ taglib prefix="cw" uri="/widget-tags"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%
	//模拟字典缓存
	java.util.Map dic = new java.util.HashMap();
	dic.put("dicSex", "[[1,'男'],[2,'女']]");
	application.setAttribute("dic", dic);
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<cw:base />
		<script type="text/javascript">
			function getSexData() {
				return [ [ 1, '男' ], [ 2, '女' ] ];
			}
			
			function showImage(v,m,r) {
		 		return "<img src=<s:url value='/'/>" + v + "></img>";
		  	}
		</script>
	</head>
	<body>
		<ul>
			<li>
				<cw:fieldSet title="动态表格" content="dyncGrid1Div" collapsible="true" collapsed="false"/>
				<div id="dyncGrid1Div">
					<cw:dynamicGrid id="dyncGrid1" title="" url="${pageContext.request.contextPath }/sample/grid/grid.query.action"
				  		exportable="false" enablePage="false" selectMode="checkbox" urlParams="{id:0}" stripeRows="true" 
				  		stripleColor="#DBEEF4" autoLoad="true" loadMask="true" forceFit="true" pageSize="5"
				  		metaUrl="${pageContext.request.contextPath }/sample/component/grid/dynamicGrid/data.json">
				  		<cw:toolBar>
				  			<cw:actionButton type="add" title="添加" split="true"></cw:actionButton>
				  			<cw:actionButton type="delete" title="删除" split="true"  url="${pageContext.request.contextPath }/sample/grid/editgrid.delete.action" 
				  			    waitMsg="正在删除数据..."/>
				  			<cw:actionButton type="update" title="保存" split="true" url="${pageContext.request.contextPath }/sample/grid/editgrid.update.action" 
				  			    waitMsg="正在保存数据..."/>
				  			<cw:actionButton type="" action="alert('总记录:'+Ext.getCmp('dyncGrid1').getStore().getTotalCount());" 
				  			    title="记录总数"/>
				  			<cw:actionButton type="copy" title="复制"/>
				  		</cw:toolBar>
				  		<cw:indexColumn indexWidth="60"/>
				   		<cw:gridColumn property="name" editable="true" editorType="string" sortable="true" width="10%" title="姓名" 
				   		    defaultValue="huyunming" align="center"/>
				   		<cw:gridColumn property="email" editable="true" editorType="email"  sortable="true" width="15%" 
				   		    defaultValue="huyunming@wondersgroup.com" align="center"/>  		
				  		<cw:gridColumn property="age" editable="true"  sortable="true" width="10%" dataType="int" 
				  			defaultValue="27" format="1,000" align="center">
				  			<cw:number property="age" allowDecimals="false" allowNegative="false"/>	 
				  		</cw:gridColumn>
				  		<cw:gridColumn property="sex" dataType="code" format="dicSex" editable="true"  sortable="true" width="15%"
				  		    editorType="int" defaultValue="1" align="center">
				  		</cw:gridColumn> 
				  	</cw:dynamicGrid>
				</div>
			</li>
		</ul>
		<cw:theme></cw:theme>
		<script type="text/javascript">
			Ext.onReady(function(){
				var STORE1 = Ext.getCmp('dyncGrid1').store;
				STORE1.on("load",function(s,r,o){
					resetHeight("dyncGridFrame");
			    });
				resetHeight("dyncGridFrame");
			})
		
			function resetHeight(frame) {
				var ifm = parent.document.getElementById(frame);
				var obj = document.body;
				var oStyle = obj.currentStyle? obj.currentStyle : window.getComputedStyle(obj, false);
				var initHeight = parseInt(document.body.clientHeight+parseInt(oStyle["margin-top"])+parseInt(oStyle["margin-bottom"]));
				ifm.height = parseInt(initHeight);
			}
		</script>
	</body>
</html>